<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('新员工登记')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>工号：</p>
                            <input type="text" name="badge"/>
                        </li>
                        <li>
                            <p>姓名：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single" onclick="$.operate.edit()">
                <i class="fa fa-edit"></i> 修改
            </a>
            &nbsp;&nbsp;&nbsp;
            <a class="btn btn-primary" onclick="threeProcedure('aSP_StaffCheck')">
                <i class="fa fa-edit"></i> 确认检查
            </a>
            <a class="btn btn-danger" onclick="threeProcedure('aSP_StaffCancel')">
                <i class="fa fa-remove"></i> 取消确认
            </a>
            <a class="btn btn-primary" onclick="threeProcedure('aSP_Staffstart')">
                执行处理
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>

<script th:inline="javascript">
    var prefix = ctx + 'attendEmpManage/NewEmpRegister';
    $(function () {
        queryData();
    })

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compName = {field: 'compName', title: '公司名称'};
        var depName = {field: 'depName', title: '部门名称'};
        var jobName = {field: 'jobName', title: '工作岗位'};
        var joinDate = {field: 'joinDate', title: '入职日期'};
        var ATStatusTitle = {field: 'ATStatusTitle', title: '考勤状态'};
        var ATEmpTypeTitle = {field: 'ATEmpTypeTitle', title: '考勤员工类型'};
        var isDXSJ = {field: 'isDXSJ', title: '是否享有带薪事假'};
        var GroupIDTitle = {field: 'GroupIDTitle', title: '轮班组'};
        var CardId = {field: 'CardId', title: '考勤卡号'};
        var AzidTitle = {field: 'AzidTitle', title: '考勤区域'};
        var Remark = {field: 'Remark', title: '备注'};
        var Initialized = {field: 'Initialized', title: '？确认'};
        var InitializedByName = {field: 'InitializedByName', title: '确认人'};
        var InitializedTime = {field: 'InitializedTime', title: '确认时间'};
        columns.push(checkbox, badge, name,compName,depName,jobName,joinDate,ATStatusTitle,ATEmpTypeTitle);
        columns.push(isDXSJ,GroupIDTitle,CardId,AzidTitle,Remark,Initialized,InitializedByName,InitializedTime);


        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + '/findAttendNewEmpRegister',
            updateUrl: prefix + "/edit/{id}",
            modalName: "添加员工",
            height: $(window).height() - 110,
            columns: columns
        };
        $.table.init(options);
    }

    function threeProcedure(procedure){
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        $.ajax({
            url: prefix + "/procedure",
            data: {"allId": allId, "procedure": procedure},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.data == null) {
                    $.modal.alertWarning(data.message);
                } else {
                    $.modal.alertSuccess(data.data);
                }

                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }

</script>
</body>
</html>